package Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Test17 {
    //按照字母大小顺序进行排序
    public static boolean isSort(String[] str){
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].compareTo(str[i+1]) > 0){
                return false;
            }
        }
        return true;
    }
    //按照字符串长度进行排序
    public static boolean isSort2(String[] str){
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].length() > str[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) throws IOException {
        //BufferedReader从字符串中读取文本并且缓存
        //把一段字符串当成一个字符给读取比如“asdf" -> "?"
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bi.readLine());
        String [] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = bi.readLine();
        }
        if(isSort(str) && isSort2(str)){
            System.out.println("Both");
        }else{
            System.out.println("None");
        }
    }






    public static int gbc (int n, int m){
        if(n == m){
            return n;
        }
        if(n < m){
            int tmp = n;
            n = m;
            m = tmp;
        }
        int a = 0;
        while((a=n%m) > 0){
            n = m;
            m = a;
        }
        return m;
    }
    public static void main1(String[] args) {
        //z最小公倍数，利用公约数求
        int n = 4;
        int m = 7;
        int d = gbc(n,m);
        System.out.println(n*m/d);
    }
}
